function sss(obj){
    var str=''
    for(var key in obj){
        str+=`${key}=${obj[key]}&`
    }
    return str.slice(0,str.length-1)
}
function ajax(fangshi,url,canshu,hd) {
    //1.先创建请求对象
    var xhr = new XMLHttpRequest()
    //2.配置请求对象参数
    xhr.open(fangshi,fangshi=='get'?url+'?'+sss(canshu):url)
    //3.配置回调函数
    xhr.onreadystatechange=function(){
        if(xhr.readyState==4){
            hd(JSON.parse(xhr.responseText))
        }
    }
    //4.最后发送
    xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
    xhr.send(fangshi=='get'?null:sss(canshu))
}